<template>
  <div class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('收款汇总') }}</span>
    </div>
    <el-form ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item :label="$t('类型')" prop="type">
        <el-select v-model="queryParams.type" @change="onChange">
          <el-option value="month" :label="$t('月')" />
          <el-option value="year" :label="$t('年')" />
        </el-select>
      </el-form-item>
      <el-form-item v-if="queryParams.type === 'year'" :label="$t('年数')" prop="num">
        <el-input-number v-model="queryParams.num" :label="$t('年数')" />
      </el-form-item>
      <el-form-item v-if="queryParams.type === 'month'" :label="$t('年份')" prop="year">
        <DatePicker v-model="queryParams.year" type="year" value-format="yyyy" :placeholder="$t('年份')" :clearable="false" />
      </el-form-item>
      <el-form-item v-if="viewType === 'teamUser'" :label="$t('项目经理')" prop="teamUserIds">
        <el-select v-model="queryParams.teamUserIds" :placeholder="$t('项目经理')" class="select" multiple collapse-tags clearable>
          <el-option
            v-for="item in teamUserList"
            :key="item.id"
            :value="item.userId"
            :label="item.user.nickName"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t("搜索") }}</el-button>
        <el-button type="primary" icon="el-icon-refresh" size="mini" @click="refreshHandle">{{ $t("刷新数据") }}</el-button>
        <el-button type="primary" icon="el-icon-warning-outline" size="mini" @click="warningCollection">{{ $t("问题收款") }}</el-button>
        <el-button type="warning" icon="el-icon-download" size="mini" @click="exportHandle">{{ $t("导出") }}</el-button>
      </el-form-item>
    </el-form>
    <el-table
      v-if="yearType === 'month'"
      v-loading="loading"
      tooltip-effect="darkTable"
      row-key="dataKey"
      :tree-props="{children: 'children',hasChildren: 'hasChildren'}"
      :data="dataList"
      border
      :cell-style="cellStyle"
      :cell-class-name="cellClassName"
      @cell-click="cellClick"
    >
      <el-table-column :label="$t('团队')" align="center" :prop="propLabelName" fixed width="150" show-overflow-tooltip />
      <el-table-column :label="$t('2月Est')" align="center" prop="februaryEst">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.februaryEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.februaryEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('2月Act')" align="center" prop="februaryAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.februaryAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.februaryAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('2月人数')" align="center" prop="februaryCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.februaryCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.februaryCount }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('3月Est')" align="center" prop="marchEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.marchEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.marchEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('3月Act')" align="center" prop="marchAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.marchAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.marchAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('3月人数')" align="center" prop="marchCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.marchCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.marchCount }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('4月Est')" align="center" prop="aprilEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.aprilEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.aprilEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('4月Act')" align="center" prop="aprilAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.aprilAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.aprilAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('4月人数')" align="center" prop="aprilCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.aprilCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.aprilCount }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('5月Est')" align="center" prop="mayEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.mayEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.mayEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('5月Act')" align="center" prop="mayAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.mayAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.mayAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('5月人数')" align="center" prop="mayCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.mayCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.mayCount }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('6月Est')" align="center" prop="juneEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.juneEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.juneEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('6月Act')" align="center" prop="juneAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.juneAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.juneAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('6月人数')" align="center" prop="juneCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.juneCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.juneCount }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('7月Est')" align="center" prop="julyEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.julyEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.julyEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('7月Act')" align="center" prop="julyAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.julyAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.julyAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('7月人数')" align="center" prop="julyCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.julyCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.julyCount }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('8月Est')" align="center" prop="augustEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.augustEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.augustEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('8月Act')" align="center" prop="augustAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.augustAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.augustAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('8月人数')" align="center" prop="augustCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.augustCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.augustCount }}</span>
        </template>
      </el-table-column>

      <el-table-column :label="$t('9月Est')" align="center" prop="septemberEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.septemberEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.septemberEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('9月Act')" align="center" prop="septemberAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.septemberAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.septemberAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('9月人数')" align="center" prop="septemberCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.septemberCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.septemberCount }}</span>
        </template>
      </el-table-column>

      <el-table-column :label="$t('10月Est')" align="center" prop="octoberEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.octoberEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.octoberEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('10月Act')" align="center" prop="octoberAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.octoberAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.octoberAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('10月人数')" align="center" prop="octoberCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.octoberCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.octoberCount }}</span>
        </template>
      </el-table-column>

      <el-table-column :label="$t('11月Est')" align="center" prop="novemberEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.novemberEst / 10000) }}</el-link>
          <span v-else>{{ moneyFormat(scope.row.novemberEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('11月Act')" align="center" prop="novemberAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.novemberAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.novemberAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('11月人数')" align="center" prop="novemberCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.novemberCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.novemberCount }}</span>
        </template>
      </el-table-column>

      <el-table-column :label="$t('12月Est')" align="center" prop="decemberEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.decemberEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.decemberEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('12月Act')" align="center" prop="decemberAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.decemberAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.decemberAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('12月人数')" align="center" prop="decemberCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ scope.row.decemberCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.decemberCount }}</span>
        </template>
      </el-table-column>

      <el-table-column :label="$t('1月Est')" align="center" prop="januaryEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.januaryEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.januaryEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('1月Act')" align="center" prop="januaryAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.januaryAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.januaryAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('1月人数')" align="center" prop="januaryCount" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" class="money-text" type="primary">{{ scope.row.januaryCount }}</el-link>
          <span v-else class="money-text">{{ scope.row.januaryCount }}</span>
        </template>
      </el-table-column>

      <el-table-column :label="$t('合计Est')" align="center" prop="totalEst" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.totalEst / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.totalEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('合计Act')" align="center" prop="totalAct" width="100">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit'" :underline="false" class="money-text" type="primary">{{ moneyFormat(scope.row.totalAct / 10000) }}</el-link>
          <span v-else class="money-text">{{ moneyFormat(scope.row.totalAct / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('团队人数')" align="center" prop="teamUserCount" width="100">
        <template slot-scope="scope">
          <a class="money-text" style="color: #1890ff" @click.stop="openTeamUser(scope.row,scope.column)">{{ moneyFormat(scope.row.teamUserCount) }}</a>
        </template>
      </el-table-column>
      <el-table-column :label="$t('人均Est')" align="center" prop="gdpEst" width="100">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.gdpEst / 10000) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('人均Act')" align="center" prop="gdpAct" width="100">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.gdpAct / 10000) }}</span>
        </template>
      </el-table-column>
    </el-table>

    <el-table
      v-if="yearType === 'year'"
      v-loading="loading"
      :cell-class-name="cellClassName"
      default-expand-all
      tooltip-effect="darkTable"
      row-key="dataKey"
      :tree-props="{children: 'children',hasChildren: 'hasChildren'}"
      :data="dataList.data"
      border
      :cell-style="cellStyle"
      @cell-click="cellClick"
    >
      <el-table-column v-for="(col) in dataList.columns" :key="col.prop" align="center" :prop="col.prop" :label="col.label">
        <template slot-scope="scope">
          <el-link v-if="scope.row.type !== 'profit' && col.prop !== '1deptName' && col.prop.indexOf('Gdp') === -1" class="money-text" type="primary" :underline="false"><span class="money-text">{{ (scope.row[col.prop] || scope.row[col.prop] === 0) ? moneyFormat(scope.row[col.prop] / 10000) : 0 }}</span></el-link>
          <span v-else-if="col.prop !== '1deptName'" class="money-text">{{ (scope.row[col.prop] || scope.row[col.prop] === 0) ? moneyFormat(scope.row[col.prop] / 10000) : 0 }}</span>
          <span v-else>{{ scope.row[col.prop] }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 添加或修改项目收款对话框 -->
    <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" top="6vh" width="80%" :lock-scroll="false" append-to-body @close="closeDialog">
      <deal-collection-list v-if="type === 'collection'" ref="dealCollectionList" :param="param" />
      <anxin-company-costs-list v-if="type === 'cost'" ref="anxinCompanyCostsList" :param="param" />
    </el-dialog>

    <!-- 添加或修改问题收款对话框 -->
    <el-dialog :title="$t('问题收款')" :visible.sync="warningCollectionOpen" :close-on-click-modal="false" :show-close="true" :before-close="close" :lock-scroll="false" custom-class="dialogForm" append-to-body>
      <warning-collection-list />
    </el-dialog>

    <el-dialog :title="teamName" :visible.sync="openUser" :close-on-click-modal="false" top="6vh" width="50%" :lock-scroll="true" append-to-body @close="closeDialog">
      <el-table v-loading="userLoading" max-height="600" tooltip-effect="darkTable" :data="userList" border :cell-style="cellStyle">
        <el-table-column :label="$t('姓名')" align="center" prop="name" min-width="150" show-overflow-tooltip />
        <el-table-column :label="$t('所在部门')" align="center" prop="deptName" min-width="100" />
        <el-table-column :label="$t('职位')" align="center" prop="positionName" min-width="100" />
        <el-table-column :label="$t('入职时间')" align="center" prop="entryTime" min-width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.entryTime) }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import {
  findCollection,
  findCollectionByTeamUserIds,
  findUserList,
  refreshReport
} from '@/api/anxin/summary/collectionSummary'
import { findByRole } from '@/api/deal/team/dealTeam'
import DealCollectionList from './dealCollectionList'
import AnxinCompanyCostsList from '@/views/anxin/costs/anxinCompanyCostsList'
import WarningCollectionList from '@/views/anxin/collectionSummary/warningCollectionList.vue'

export default {
  components: { WarningCollectionList, AnxinCompanyCostsList, DealCollectionList },
  data() {
    return {
      title: '',
      open: false,
      dataList: [],
      loading: false,
      queryParams: {
        year: undefined,
        type: 'month',
        teamUserIds: undefined,
        num: 3
      },
      param: undefined,
      type: undefined,
      viewType: this.$route.query.viewType,
      teamUserList: [],
      propLabelId: this.$route.query.viewType === 'teamUser' ? 'teamUserId' : 'deptId',
      propLabelName: this.$route.query.viewType === 'teamUser' ? 'teamUserName' : (this.yearType === 'year' ? '1deptName' : 'deptName'),
      userList: [],
      userLoading: true,
      openUser: false,
      teamName: '',
      yearType: 'month',
      warningCollectionOpen: false
    }
  },
  created() {
    this.queryParams.year = (this.parseTime(new Date(), '{m}') === '01' ? (parseInt(this.parseTime(new Date(), '{y}')) - 1) : this.parseTime(new Date(), '{y}')).toString()
    this.getList()
  },
  mounted() {
    if (this.viewType === 'teamUser') {
      findByRole('X').then(res => {
        this.teamUserList = res.data
      })
    }
  },
  methods: {
    getRowKey(row) {
      return row.datakey
    },
    getList(type = 'month') {
      this.loading = true
      if (this.viewType === 'teamUser') {
        findCollectionByTeamUserIds(this.queryParams).then(response => {
          this.dataList = response.data
          this.loading = false
        })
      } else {
        findCollection(this.queryParams).then(response => {
          this.dataList = response.data
          this.yearType = type
          setTimeout(() => {
            this.loading = false
          }, 200)
        })
      }
    },
    queryHandle() {
      this.getList(this.yearType)
    },
    refreshHandle() {
      this.loading = true
      // eslint-disable-next-line no-unused-vars
      refreshReport().then(res => {
        this.$message.info('计算中,请稍后进行查看......')
        this.getList(this.yearType)
      })
    },
    onChange() {
      this.getList(this.queryParams.type)
    },
    cellStyle({ row }) {
      var propLabelName = this.yearType === 'year' ? (this.viewType === 'teamUser' ? 'teamUserName' : '1deptName') : (this.viewType === 'teamUser' ? 'teamUserName' : 'deptName')
      if (row[propLabelName].indexOf('合计') >= 0) {
        return 'color:#303133;background-color:#E6A23C'
      }
    },
    openTeamUser(row, column) {
      var month = column.property.substring(0, column.property.length - 5)
      this.userLoading = true
      this.teamName = row.deptName
      findUserList({ year: this.queryParams.year, month: month, type: row.type }, row.deptId).then(res => {
          this.userList = res.data
          this.userLoading = false
          this.openUser = true
      })
    },
    cellClick(row, column) {
      this.param = this.resolvingProperty(column.property)

      if (this.param.category === 'unt') {
        this.openTeamUser(row, column)
        return
      }
      switch (row.type) {
        case 'collection':
          this.open = true
          this.type = row.type
          this.param = this.resolvingProperty(column.property)
          if (this.yearType === 'year') {
            this.param.year = this.param.month
          } else {
            this.param.year = this.queryParams.year
          }
          this.param.deptId = row[this.propLabelId]
          if (this.viewType === 'teamUser') {
            this.param.type = 'teamUser'
            if (row[this.propLabelId] === 'hj') {
              this.param.teamUserIds = this.queryParams.teamUserIds
            } else {
              this.param.teamUserIds = []
              this.param.teamUserIds.push(row[this.propLabelId])
            }
          }
          this.title = this.$t('项目回款')
          this.$nextTick(() => {
            this.$refs.dealCollectionList.getList()
          })
          break
        case 'cost':
          this.open = true
          this.type = row.type
          this.param = this.resolvingProperty(column.property)
          if (this.yearType === 'year') {
            this.param.year = this.param.month
          } else {
            this.param.year = this.queryParams.year
          }
          this.title = this.$t('公司成本')
          this.$nextTick(() => {
            this.$refs.anxinCompanyCostsList.getList()
          })
          break
        default:
          return
      }
    },
    // 解析table-column-prop
    resolvingProperty(val) {
      // 截取月份
      var month = val.substring(0, val.length - 3)
      // 截取后三位 Est/Act
      var category = val.substring(val.length - 3, val.len).toLowerCase()
      return { month, category }
    },
    closeDialog() {
      // this.getList(this.queryParams.type)
    },
    /** 导出按钮操作 */
    exportHandle() {
      this.queryParams.exportType = 'list'
      this.downLoadExcel('/collection/dealCollection/exportCollectionSummary', this.queryParams)
    },

    /**
     * 问题收款
     */
    warningCollection() {
      this.warningCollectionOpen = true
    },

    /**
     * 列变色
     */
    cellClassName({ columnIndex, column }) {
      if (this.yearType === 'month') {
        if ((columnIndex !== 0 && columnIndex % 6 === 0 || columnIndex !== 0 && columnIndex % 6 === 4 || columnIndex !== 0 && columnIndex % 6 === 5 || columnIndex !== 0 && columnIndex % 6 === 6) && !(column.label.indexOf('人均E') > -1 || column.label.indexOf('人均A') > -1)) {
          return 'gray'
        }
        if (column.label.indexOf('合计') > -1 || column.label.indexOf('团队人数') > -1 || column.label.indexOf('人均E') > -1 || column.label.indexOf('人均A') > -1) {
          return 'yellow'
        }
      }
      if (this.yearType === 'year') {
        var year = new Date().getFullYear()
        if ((columnIndex !== 0 && columnIndex % 4 === 0 || columnIndex !== 0 && columnIndex % 4 === 3) && column.label.indexOf(year + '') === -1) {
          return 'gray'
        }
        if (this.queryParams.num % 2 === 0 && column.label.indexOf(year + '') !== -1) {
          return 'gray'
        }
      }
      return ''
    }
  }
}
</script>

<style scoped>
.select /deep/ .el-input {
  width: auto !important;
}
a:hover{
  text-decoration: underline;
}
/deep/.gray {
  background-color: #eee;
}
/deep/ .yellow{
  color:#303133;
  background-color:#e8e8e8
}
</style>
